package com.lm.paymentweb.common;

import java.io.Serializable;
import java.util.Date;

/**
 * @author liu2dog
 */
public class Result implements Serializable {
    private int status;
    private String message;
    private Object data;
    private Date timestamp;
    public static Result ok(Object data) {
        Result m = new Result();
        m.setStatus(200);
        m.setData(data);
        m.setMessage("操作成功");
        m.setTimestamp(new Date());
        return m;
    }
    public static Result ok(String mess, Object data) {
        Result m = new Result();
        m.setStatus(200);
        m.setData(data);
        m.setMessage(mess);
        m.setTimestamp(new Date());
        return m;
    }
    public static Result fail(String mess) {
        Result m = new Result();
        m.setStatus(-1);
        m.setData(null);
        m.setMessage(mess);
        m.setTimestamp(new Date());
        return m;
    }

    public static Result fail(String mess, Object data) {
         Result m = new Result();
         m.setStatus(-1);
         m.setData(data);
         m.setMessage(mess);
         m.setTimestamp(new Date());
         return m;
    }
    public static Result fail(int code,String mess, Object data) {
        Result m = new Result();
        m.setStatus(code);
        m.setData(data);
        m.setMessage(mess);
        m.setTimestamp(new Date());
        return m;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }
}
